using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerDashState : PlayerState
{
    public PlayerDashState(Player player, PlayerStateMachine playerStateMachine, string animBoolName) : base(player, playerStateMachine, animBoolName)
    {
    }

    public override void Enter()
    {
        base.Enter();
        player.stat.SetWuDi(true);
        stateTime = player.dashTime;
        player.skill.dash.CloneOnDashStart();
    }

    public override void Exit()
    {
        base.Exit();
        player.stat.SetWuDi(false);
        rb.velocity = new Vector2(0, rb.velocity.y);
        player.skill.dash.CloneOnDashOver();
    }

    public override void Update()
    {
        base.Update();
        player.playerFx.CreateDashImage();
        if ((player.dashDir <0&& player.faceDir>0)|| (player.dashDir > 0 && player.faceDir<0))
            player.Flip();
        rb.velocity = new Vector2(player.dashDir * player.dashSpeed,0 );
        if (stateTime < 0)
            playerStateMachine.ChangeState(player.playerIdleState);
        if(!player.isGround()&&player.IsWall())
            playerStateMachine.ChangeState(player.playerWallSlideState);
    }
}
